package com.yanfan.visitor.controller;

import java.util.Arrays;
import java.util.List;
import javax.validation.Valid;
import javax.servlet.http.HttpServletResponse;
import com.yanfan.common.utils.DateUtils;
import com.yanfan.common.utils.SecurityUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yanfan.common.annotation.Log;
import com.yanfan.common.core.controller.BaseController;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.enums.BusinessType;
import com.yanfan.visitor.domain.IbmsVisitorInfo;
import com.yanfan.visitor.service.IIbmsVisitorInfoService;
import com.yanfan.common.utils.poi.ExcelUtil;
import com.yanfan.common.core.page.TableDataInfo;

/**
 * 访客记录信息Controller
 *
 * @author mzp
 * @date 2024-08-26
 */
@Api(tags = "访客记录信息")
@RestController
@RequestMapping("/visitor/visitorInfo")
public class IbmsVisitorInfoController extends BaseController {
    @Autowired
    private IIbmsVisitorInfoService ibmsVisitorInfoService;

    /**
     * 查询访客记录信息列表
     */
    @ApiOperation("访客记录信息分页列表")
    @PreAuthorize("@ss.hasPermi('visitor:visitorInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(IbmsVisitorInfo ibmsVisitorInfo) {
        startPage();
        List<IbmsVisitorInfo> list = ibmsVisitorInfoService.queryPageList(ibmsVisitorInfo);
        return getDataTable(list);
    }

    /**
     * 导出访客记录信息列表
     */
    @ApiOperation("导出访客记录信息列表")
    @PreAuthorize("@ss.hasPermi('visitor:visitorInfo:export')")
    @Log(title = "访客记录信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IbmsVisitorInfo ibmsVisitorInfo) {
        List<IbmsVisitorInfo> list = ibmsVisitorInfoService.queryPageList(ibmsVisitorInfo);
        ExcelUtil<IbmsVisitorInfo> util = new ExcelUtil<IbmsVisitorInfo>(IbmsVisitorInfo.class);
        util.exportExcel(response, list, "访客记录信息数据");
    }

    /**
     * 获取访客记录信息详细信息
     */
    @ApiOperation("获取访客记录信息详细信息")
    @PreAuthorize("@ss.hasPermi('visitor:visitorInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(ibmsVisitorInfoService.getById(id));
    }

    /**
     * 新增访客记录信息
     */
    @ApiOperation("新增访客记录信息")
    @PreAuthorize("@ss.hasPermi('visitor:visitorInfo:add')")
    @Log(title = "访客记录信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Valid @RequestBody IbmsVisitorInfo ibmsVisitorInfo) {
        return toAjax(ibmsVisitorInfoService.save(ibmsVisitorInfo));
    }

    /**
     * 修改访客记录信息
     */
    @ApiOperation("修改访客记录信息")
    @PreAuthorize("@ss.hasPermi('visitor:visitorInfo:edit')")
    @Log(title = "访客记录信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Valid @RequestBody IbmsVisitorInfo ibmsVisitorInfo) {
        return toAjax(ibmsVisitorInfoService.updateById(ibmsVisitorInfo));
    }

    /**
     * 删除访客记录信息
     */
    @ApiOperation("删除访客记录信息")
    @PreAuthorize("@ss.hasPermi('visitor:visitorInfo:remove')")
    @Log(title = "访客记录信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(ibmsVisitorInfoService.removeBatchByIds(Arrays.asList(ids)));
    }
}
